package com.gec.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.model.system.SysOperLog;
import com.gec.model.vo.SysOperLogQueryVo;
import com.gec.system.service.SysOperLogService;
import com.gec.system.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("登录日志控制器")
@RestController
@RequestMapping("/admin/system/sysOperLog")
public class SysOperLogController {
    @Autowired
    private SysOperLogService sysOperLogService;

    @ApiOperation(value = "获取分页列表")
    @GetMapping("{page}/{limit}")
    public Result QueryLoginLog(@PathVariable Long page, @PathVariable Long limit, SysOperLogQueryVo sysOperLogQueryVo) {
        IPage<SysOperLog> iPage = sysOperLogService.selectPage(page, limit, sysOperLogQueryVo);
        System.out.println("iPage = " + iPage);
        return Result.ok(iPage);
    }


    @ApiOperation("删除单个LoginLog")
    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Long id){
        this.sysOperLogService.removeById(id);
        return Result.ok();
    }

    @ApiOperation("逻辑批量删除")
    @DeleteMapping("/deleteIds")
    public Result deleteIds(@RequestBody List<Long> ids){
        System.out.println("ids = " + ids);
        this.sysOperLogService.removeIds(ids);
        return Result.ok();
    }
}
